/**
 * 
 */
package org.metaverse.restful;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

import org.osgi.framework.BundleContext;
import org.restlet.security.SecretVerifier;

/**
 * @author vjache
 *
 */
public class VerifierImpl extends SecretVerifier {
	
	private Map<String, char[]> _authDb = new HashMap<String, char[]>();

	/**
	 * @param bundleContext 
	 * 
	 */
	public VerifierImpl(BundleContext bundleContext) {
		_authDb.put("scott", "tiger".toCharArray());
		_authDb.put("brahma", "admin".toCharArray());
	}

	/* (non-Javadoc)
	 * @see org.restlet.security.SecretVerifier#verify(java.lang.String, char[])
	 */
	@Override
	public boolean verify(String aIdentity, char[] aPass)
			throws IllegalArgumentException {
		final char[] pass = _authDb.get(aIdentity);
		return pass!=null & Arrays.equals(aPass, pass);
	}

}
